package com.example.shipload_e;

import com.example.shipload_e.activitys.menu_activity.ModifyPasswordActivity;
import com.example.shipload_e.util.SharePreferenceUtil;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;

public class LeftMenuFragment extends Fragment {
	private SharePreferenceUtil	spu;
	private ImageButton	        modifyAction, exitId, updateVersion;

	@Override
	public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.left_menu_main, container, false);
		spu = new SharePreferenceUtil(getActivity());
		modifyAction = (ImageButton) view.findViewById(R.id.modify_action);
		modifyAction.setOnClickListener(ocl);
		exitId = (ImageButton) view.findViewById(R.id.exit_ib);
		exitId.setOnClickListener(ocl);
		updateVersion = (ImageButton) view.findViewById(R.id.update_version);
		updateVersion.setOnClickListener(ocl);
		return view;
	}

	private final OnClickListener	ocl	= new OnClickListener() {

		                                    @Override
		                                    public void onClick(View arg0) {
			                                    switch (arg0.getId()) {
													case R.id.modify_action:
														startActivity(new Intent(getActivity(), ModifyPasswordActivity.class));

														break;
													case R.id.exit_ib:
														spu.setAccount("");
														spu.setPassword("");
														startActivity(new Intent(getActivity(), MainActivity.class));

														break;
													case R.id.update_version:
														break;

													default:
														break;
												}
											}

	                                    };

}
